<?php

    require_once ('../lib/core.php');

    session_unregister($CF['Sys']['SecretKey']);

    function GetUser($UserName='',$PassWord='') {
        global $CF,$Vezir;
        $PassWord = "md5:".md5($PassWord);
        $Query = $Vezir->GetRecord($CF['Db']['UsersTable'],'*','','WHERE UserName="'.$UserName.'" AND UserPass="'.$PassWord.'"');
        return $Query;
    }

    if (array_key_exists('login',$_GET)) {
        $Vezir = new Vezir($CF['Db']);
        if ($Raw=GetUser($_POST['username'],$_POST['password'])) {
            session_register($CF['Sys']['SecretKey']);
            $_SESSION['User'] = $Raw[0];
            header('location: index.php');
        }
        else
           ssv('Message','1');
    }

    $smarty->display('admin/index.html');

?>
